# -*- coding: utf-8 -*-
# @Time    : 2021/5/6 9:41
# @Author  : Chen
# @Email   : 2356458272@qq.com
# @File    : atm.py
# @Software: PyCharm
class Atm():
    money = 50000
    def __init__(self,name):
        self.name = name
    def get_money(self,getmoney):
        self.money = self.money - getmoney
    def give_money(self,givemoney):
        self.money = self.money + givemoney
class User():
    def __init__(self,username,passwd):
        self.username = username
        self.passwd = passwd
        self.money = 0
    def gt_money(self,gtmoney,atmuser):
        if self.money > gtmoney and atmuser.money > gtmoney:
            self.money = self.money - gtmoney
            atmuser.money = atmuser.money -gtmoney
        else:
            print("余额不足")
    def gv_money(self,gvmoney,atmuser):
        self.money = self.money + gvmoney
        atmuser.money = atmuser.money + gvmoney
    def chaxun(self):
        print(self.money)

user = dict()
atm = dict()
# 创建Atm，输入atm的名字
c = input("请输入atm名字：")
atm[c] = Atm(c)
print("输入0创建用户，输入1登录用户")
h = input("请输入：")
while 1:
    # 创建用户,输入用户名和密码
    if h == 0:
        a,b = input("请输入用户名，密码").split()
        user[a]=User(a,b)
    # 登录用户
    elif h == 1:
        e = input("请输入用户名：")
        if e in user:
            f = input("请输入密码：")
            if user[e].passwd == f:
                print("登录成功")
                print("输入2取钱，3存钱，4查询")
                i = input("请输入：")
    # # 创建Atm，输入atm的名字
    # c = input("请输入atm名字：")
    # atm[c] = Atm(c)
            # 取钱,在哪台机器取钱
                if i == 2:
                    m = input("请输入需要取多少钱：")
                    user[e].gt_money(m,atm[c])
            # 存钱，在哪台机器存钱
                elif i == 3:
                    m = input("请输入要存多少钱：")
                    user[e].gv_money(m,atm[c])
            # 查询
                elif i == 4:
                    user[e].chaxun()

# 斐波拉契数列
# class fblq():
#     num=0
#     num2=1
#     def __iter__(self):
#         return self
#     def __next__(self,geshu):
#         self.geshu = geshu
#         for i in range(self.geshu):
#             fblq.num, fblq.num2 = fblq.num2, fblq.num + fblq.num2
#             print(fblq.num)
#
# a=fblq()
# a.__next__(5)